<template>
  <div id="voice_detail">
    <c-title :hide="false" :text="'音频详情'"></c-title>
    <div id="content" v-if="isShow === 1">
      <div class="content_a">
        <div class="banner">
          <div class="image" v-if="dataInfo.thumb"><img :src="dataInfo.thumb" /></div>
          <div class="image" v-if="!dataInfo.thumb">
            <img src="../../../../assets/images/img_default.png" />
          </div>
        </div>
        <div class="topA">
          <h1>{{ dataInfo.title }}</h1>
          <div class="author">作者：{{ dataInfo.author }}</div>
        </div>
        <div class="audio-wrapper">
          <audio
            id="audio"
            ref="audio"
            @pause="onPause"
            @play="onPlay"
            @timeupdate="onTimeupdate"
            @loadedmetadata="onLoadedmetadata"
            controls="controls"
            style="display: none"
            :src="dataInfo.audio_link"
          >
            <!--<source-->
            <!--:src="dataInfo.audio_link"-->
            <!--type="audio/mp3">-->
            您的浏览器不支持 audio 标签！
          </audio>
          <div class="audio-left">
            <img @click="startPlayOrPause" v-if="isPlay && readyState > 0" src="../../../../assets/images/play.png" />
            <img @click="startPlayOrPause" v-if="!isPlay && readyState > 0" src="../../../../assets/images/pause.png" />
            <img v-if="readyState < 1" src="../../../../assets/images/loading.gif" />
          </div>
          <div class="slider" :ref="`slidre`+i" @touchstart="handleTouchStart($event,i)">
            <div class="slider-track"></div>
            <div class="slider-fill" :style="'width:' + sliderTime + '%'"></div>
            <div class="slider-thumb" :style="'left:' + sliderTime + '%'"></div>
          </div>
          <div class="time">
            <div class="time_left">{{ audio.currentTime | formatSecond }}</div>
            <div class="time_right">{{ audio.maxTime | formatSecond }}</div>
          </div>
        </div>
      </div>
      <div class="content_b">
        <h2>
          【音频简介】<span>{{ dataInfo.created_at }}</span>
        </h2>
        <div class="text" v-html="dataInfo.content"></div>
      </div>
      <div class="paddingbox">
        <div class="foot_advs" @click="toAdvs()" v-if="is_advs_type">
          <p class="advs_title">{{ dataInfo.advs_title }}</p>
          <div class="advs_img_bg" v-if="dataInfo.advs_img">
            <img class="advs_img" :src="dataInfo.advs_img" />
          </div>
          <div class="advs_img_bg" v-if="!dataInfo.advs_img">
            <img class="advs_img" src="@/assets/images/img_default.png" />
          </div>
          <div class="advs_desc">{{ dataInfo.advs_title_footer }}</div>
        </div>
        <div class="foot">
          <div>
            <h4 class="read">阅读 {{ read_num }}</h4>
            <h4 class="like" @click="like(like_num)">{{ is_liked ? "已点赞" : "点赞" }} {{ like_num }}</h4>
            <h4 class="like" v-if="comment" style="padding-left: 0.625rem">评论({{ commentNum }})</h4>
          </div>
          <div v-if="is_report_enabled">
            <h4 class="report" @click="report()">举报</h4>
          </div>
          <div v-if="is_link">
            <h4 class="link" @click="link()">阅读原文</h4>
          </div>
        </div>
      </div>
      
      
      <div class="content_c" v-if="codeUrl">
        <h3>【二维码】</h3>
        <div class="code">
          <span>长按识别二维码</span>
          <div class="img">
            <img :src="codeUrl" />
          </div>
        </div>
      </div>
      <!-- 评论 -->
      <div class="comment" v-if="comment">
        <div style="width: 100%; height: 0.31rem; background: #f2f2f2"></div>
        <div class="title">评论详情</div>
        <div class="commentList">
          <div class="firstComment" v-for="(item, ind) in commentList" :key="ind" @click.stop="delComment(item, ind)">
            <div class="userTop">
              <div class="image">
                <img :src="item.head_image" alt="" />
              </div>
              <div class="user">
                <div class="userName">{{ item.nick_name }}</div>
                <div class="dateDay">{{ item.created_at }}</div>
                <div class="contenBox">
                  <div class="txt">{{ item.content }}</div>
                  <div class="contenImg" v-if="item.comment_images.length > 0" @click.stop="watchImg(item.comment_images)">
                    <img :src="item.comment_images" alt="" />
                  </div>
                </div>
              </div>
              <div class="reply" @click.stop="replyBtn(item.nick_name, item, ind)">回复</div>
            </div>
            <!-- 回复的评论 -->
            <div class="commentLis" v-show="item.child" v-for="(info, index) in item.child" :key="index" @click.stop="delComment(info, ind, index, 'child')">
              <div class="userTop">
                <div class="image">
                  <img :src="info.head_image" alt="" v-if="info.head_image" />
                  <img src="@/assets/images/photo-mr.jpg" alt="" v-else />
                </div>
                <div class="user">
                  <div class="userName">{{ info.nick_name }}</div>
                  <div class="dateDay">{{ info.updated_at }}</div>
                  <div class="contenBox">
                    <div class="txt">
                      <div v-if="info.reply_id != '0' || info.reply_name">回复{{ info.reply_name }}:</div>
                      {{ info.content }}
                    </div>
                    <div class="contenImg" v-show="info.comment_images" @click.stop="watchImg(info.comment_images)">
                      <template v-for="(datas, indkey) in info.comment_images">
                        <img :src="datas" alt="" :key="indkey" />
                      </template>
                    </div>
                  </div>
                </div>
                <div class="reply" @click.stop="replyBtn(info.nick_name, info, ind)">回复</div>
              </div>
            </div>
            <!-- 展开更多 加在更多评论 -->
            <div class="commentLis" v-if="item.reply_num > 0 && item.commentShow">
              <div class="commentMore" @click.stop="moreCommentLis(item.id, ind)">
                显示展开{{ item.reply_num }}条回复
                <van-icon name="arrow-down" />
              </div>
            </div>
          </div>
          <div class="commentMore" v-if="commentPage < last_page" @click="getMore">
            展开更多的评论
            <van-icon name="arrow-down" />
          </div>
        </div>
        <!-- 回复输入框 -->
        <div class="replyInp">
          <div class="userImg">
            <img :src="commenMember.avatar_image" alt="" />
          </div>
          <div class="inpNav" @click="subMainCommentBtn">
            <input disabled type="text" placeholder="来都来了，留下点什么吧" />
          </div>
        </div>
        <yz-comment-input v-model="showCommentInput" v-on:confirm="subMainBtn" :options="commentInputOptions">
          <div class="commentInput-slot-style" v-if="commentInputOptions.type == 'reply'">
            回复<span class="selcolor">@{{ replyName }}</span>
          </div>
        </yz-comment-input>
      </div>
      <van-image-preview v-model="showImg" :images="imgList" :start-position="imgStart"></van-image-preview>
    </div>
  </div>
</template>

<script>
import voice_detail_controller from "./voice_detail_controller";

export default voice_detail_controller;
</script>

<style lang="scss" rel="stylesheet/scss" scoped>
.comment {
  background-color: #fff;
  padding-bottom: 1.94rem;

  .replyInp {
    width: 100%;
    height: 3.13rem;
    background-color: #fff;
    padding-left: 0.94rem;
    padding-right: 1.28rem;
    display: flex;
    align-items: center;
    box-shadow: -0.01rem 0.09rem 0.91rem 0 rgba(188, 188, 188, 0.57);

    .userImg {
      width: 2.19rem;
      height: 2.19rem;
      border-radius: 100%;

      img {
        width: 2.19rem;
        height: 2.19rem;
        border-radius: 100%;
      }
    }

    .inpNav {
      flex: 1;
      height: 1.88rem;
      background: #f5f5f5;
      border-radius: 0.94rem;
      padding-left: 0.97rem;
      margin-left: 0.66rem;

      input {
        width: 100%;
        height: 100%;
        outline: none;
        border: none;
      }
    }
  }

  .title {
    font-size: 1rem;
    color: #202020;
    text-align: left;
    padding-top: 1.06rem;
    padding-left: 0.97rem;
    padding-bottom: 1.16rem;
    box-sizing: border-box;
  }

  .commentList {
    padding: 1.13rem 0.94rem;

    .firstComment {
      .userTop {
        display: flex;

        .user {
          flex: 1;
          text-align: left;
          height: 100%;

          .userName {
            font-size: 1rem;
            color: #2e2e2e;
          }

          .dateDay {
            font-size: 0.63rem;
            color: #767676;
          }

          .contenBox {
            margin-top: 0.88rem;
            width: 100%;

            .txt {
              font-size: 0.94rem;
              color: #2e2e2e;
              margin-bottom: 0.63rem;
              display: flex;
            }

            .contenImg {
              display: flex;
              justify-content: flex-start;

              img {
                width: 3rem;
                height: 3rem;
                background-color: #c1c1c1;
                border-radius: 0.13rem;
                margin: 0;
                margin-right: 0.25rem;
              }
            }
          }
        }

        .image {
          width: 2.5rem;
          height: 2.5rem;
          background-color: #b5b5b5;
          border-radius: 50%;
          margin-right: 0.63rem;

          img {
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
          }
        }

        .reply {
          font-size: 0.88rem;
          line-height: 1.27rem;
          letter-spacing: 0.02rem;
          color: #f15353;
        }
      }

      .commentLis {
        margin-top: 0.94rem;
        margin-left: 1.16rem;

        .userTop {
          display: flex;

          .user {
            flex: 1;
            text-align: left;
            height: 100%;

            .userName {
              font-size: 0.88rem;
              color: #2e2e2e;
            }

            .dateDay {
              font-size: 0.63rem;
              color: #767676;
            }

            .contenBox {
              margin-top: 0.88rem;
              width: 100%;

              .txt {
                font-size: 0.88rem;
                color: #2e2e2e;
                margin-bottom: 0.63rem;
              }

              .contenImg {
                display: flex;
                justify-content: flex-start;

                img {
                  width: 3rem;
                  height: 3rem;
                  background-color: #c1c1c1;
                  border-radius: 0.13rem;
                  margin: 0;
                  margin-right: 0.25rem;
                }
              }
            }
          }

          .image {
            width: 1.88rem;
            height: 1.88rem;
            background-color: #b5b5b5;
            border-radius: 50%;
            margin-right: 0.63rem;

            img {
              width: 1.88rem;
              height: 1.88rem;
              border-radius: 50%;
            }
          }

          .reply {
            font-size: 0.69rem;
            line-height: 1.27rem;
            letter-spacing: 0.02rem;
            color: #f15353;
          }
        }
      }
    }
  }
}
.foot {
  height: 1.875rem;
  h4 {
    text-align: left;
    font-size: 18px;
  }

  h4.like {
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }

  h4.read {
    padding-right: 0.625rem;
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }

  h4.report {
    padding-right: 0.625rem;
    float: right;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }

  h4.link {
    padding-right: 0.625rem;
    float: right;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }

  h4.copy {
    padding-right: 0.625rem;
    float: left;
    color: #8a8a8a;
    text-align: left;
    font-size: 16px;
  }
}
.paddingbox{
  padding: 0 1rem;
  background: #fff;
}
.foot_advs {
  margin-bottom: 1.25rem;
  height: auto;
  border: 0.0625rem solid #ddd;
  padding: 0.3125rem 0.3125rem;
  background: #fff;
  width: 100%;
  border-radius: 0;
  .advs_img_bg {
    width: 100%;
    margin-bottom: 0.625rem;
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
  }
  .advs_img {
    width: 100%;
  }
  .advs_desc {
    padding-left: 0.3125rem;
    padding-right: 0.3125rem;
    text-align: left;
    font-size: 14px;
    color: #8a8a8a;
  }
  p.advs_title {
    padding-left: 0.3125rem;
    padding-right: 0.3125rem;
    text-align: left;
    height: 1.875rem;
    line-height: 1.875rem;
    font-size: 16px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: bold;
  }
}
#voice_detail {
  #content {
    .content_a {
      background: #fff;
      padding-bottom: 0.625rem;

      .banner {
        width: 100%;
        height: auto;
        overflow: hidden;
        background: #f5f5f5;

        img {
          width: 100%;
          height: auto;
        }
      }
      .topA{
        display: flex;
        justify-content: space-between;
        padding: 0 0.875rem;
        align-items: center;
      }
      h1 {
        font-size: 16px;
        height: 2.5rem;
        line-height: 2.5rem;
        text-align: left;
        
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .author {
        color: #867e7e;
        flex-shrink: 0;
      }
      .audio-wrapper {
        background-color: #fcfcfc;
        margin: 10px auto;
        width: 100%;
        height: 70px;
        border: 1px solid #e0e0e0;
        color: #3e3e3e;
      }

      .audio-left {
        float: left;
        text-align: center;
        width: 18%;
        height: 100%;
      }

      .audio-left img {
        width: 40px;
        position: relative;
        top: 15px;
        margin: 0;
        display: initial; /* 解除与app的样式冲突 */
        cursor: pointer;
      }

      .slider {
        width: 80%;
        position: relative;
        height: 30px;
        margin-top: 20px;
        display: flex;
        align-items: center;
        cursor: default;
        user-select: none;
        outline: none;
      }

      .slider-track {
        position: absolute;
        height: 2px;
        left: 0;
        right: 0;
        top: 50%;
        margin-top: -1px;
        background-color: #bec2c1;
      }

      .slider-fill {
        position: absolute;
        height: 2px;
        width: 100%;
        background-color: #28a4e9;
        left: 0;
        top: 50%;
        margin-top: -1px;
      }

      .slider-thumb {
        position: absolute;
        top: 50%;
        width: 12px;
        height: 12px;
        background-color: #28a4e9;
        color: #28a4e9;
        border-radius: 50%;
        transform: translate(-50%, -50%);
        cursor: pointer;
      }

      .time {
        display: flex;
      }

      .time_left {
        flex: 1;
        text-align: left;
      }

      .time_right {
        flex: 0 0 3rem;
        padding-right: 1rem;
      }
    }

    .content_b {
      background: #fff;
      margin-top: 0.625rem;

      h2 {
        height: 2.5rem;
        line-height: 2.5rem;
        font-size: 16px;
        display: flex;
        justify-content: space-between;
        padding: 0 0.875rem;

        span {
          font-size: 14px;
          color: #8c8c8c;
          font-weight: normal;
        }
      }

      .text {
        padding: 0.625rem 1.25rem;
        text-align: left;
        font-size: 14px;
        color: #666;
      }
    }

    .content_c {
      background: #fff;
      margin-top: 0.625rem;
      padding-bottom: 1.25rem;

      h3 {
        height: 2.5rem;
        line-height: 2.5rem;
        font-size: 16px;
        text-align: left;
        padding: 0 0.875rem;
      }

      .code {
        span {
          color: #8c8c8c;
        }

        .img {
          width: 7.5rem;
          height: 7.5rem;
          overflow: hidden;
          background: #f5f5f5;
          margin: 0.625rem auto;

          img {
            width: 100%;
          }
        }
      }
    }
  }
}
</style>
<style lang="scss" rel="stylesheet/scss">
#voice_detail {
  img {
    display: block;
    max-width: 100% !important;
    height: auto !important;
  }

  iframe {
    width: 100% !important;
  }

  li {
    list-style: inherit;
  }
}
</style>